
use PolBehaviorData, clear

**************************
**************************
*********Analysis*********
**************************
**************************

**Table 1**

	*Party ID*
	tab partyid if staff !=.
	*Candidate Type
	tab inc if staff !=.
	tab seattype if inc ==0 & staff!=.
		*Open Seats*
		display 56/(172+20) 
		*Incumbents*
		display 20/(172+20)
		*Challengers*
		display (43+73)/(172+20)
	*Primary Election Characteristics
	tab competitiveprimaryrace if staff !=.
	tab wonprimary if staff!=.
	*Staff Type*
	tab staff
	*Office Sought*
	tab seatgsh if staff !=.
	*Demographics
	tab female if staff!=.
	*Campaign Experience*
	tab experience if staff!=.
	

**Table 2**
logit sawahead female i.partyid inc i.staff i.officesought i.wonprimary

**Table 3**
logit choosenegative sawahead 
logit choosenegative sawahead if partyid !=0
logit choosenegative sawahead##i.female 
logit choosenegative sawahead##i.partyid if partyid !=0
logit choosenegative sawahead##candidatedummy

	*Point Estimates*
	logit choosenegative sawahead 
		margins, at(sawahead=1)
		margins, at(sawahead=0)
		
	logit choosenegative sawahead if partyid !=0
		margins, at(sawahead=1)
		margins, at(sawahead=0)
		
	**Table 1A in Appendix**
	logit choosenegative sawahead##i.female if partyid!=0	
	logit choosenegative sawahead##candidatedummy if partyid!=0
	logit choosenegative sawahead##candfemale if partyid!=0



**Figure 1**
reshape long negrange_1, i(id) j (campaignstatus)
gen sqcampaignstatus=campaignstatus^2		

ologit negrange_1 campaignstatus sqcampaignstatus i.partyid female inc i.officesought, cluster (id)
margins, at((means)_all campaignstatus=1 sqcampaignstatus=1 )
margins, at((means)_all campaignstatus=2 sqcampaignstatus=4 )
margins, at((means)_all campaignstatus=3 sqcampaignstatus=9 )
margins, at((means)_all campaignstatus=4 sqcampaignstatus=16)
margins, at((means)_all campaignstatus=5 sqcampaignstatus=25 )
margins, at((means)_all campaignstatus=6 sqcampaignstatus=36 )
margins, at((means)_all campaignstatus=7 sqcampaignstatus=49 )
//Actual figure was created in Excel from the point estimates and confidence intervals generated here

	**Table 2A in Appendix
	ologit negrange_1 campaignstatus, cluster (id)	
	ologit negrange_1 campaignstatus sqcampaignstatus , cluster (id)	
	ologit negrange_1 campaignstatus sqcampaignstatus if partyid !=0, cluster (id)
	ologit negrange_1 campaignstatus sqcampaignstatus i.partyid female inc i.officesought i.wonprimary, cluster (id)
	ologit negrange_1 campaignstatus sqcampaignstatus i.partyid female inc i.officesought i.wonprimary if partyid !=0, cluster (id)

	
	**Table 3A in Appendix
	xtset id
	xtologit negrange_1 campaignstatus
	xtologit negrange_1 campaignstatus if partyid !=0
	
	**Table 4A in Appendix
	xtreg negrange_1 campaignstatus, fe
	xtreg negrange_1 campaignstatus if partyid!=0, fe	
		
